package com.crm.controller;

import com.crm.dto.ContractDto;
import com.crm.vo.ClientsVO;
import com.crm.dto.CountDto.ClientsDto;
import com.crm.result.PageResult;
import com.crm.result.PageResultTow;
import com.crm.service.BusinessService;
import com.crm.service.ContractService;
import com.crm.service.impl.ContractServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j

public class CountController {

    @Autowired
    private ContractService contractService;


    @GetMapping("/report/contractStatisticsList")
    public PageResultTow contractStatisticsList(ClientsDto clientsDto){
        log.info("统计客户信息{}",clientsDto);
        PageResult res = contractService.ClientsPage(clientsDto);
        return PageResultTow.success(res.getRows(), res.getTotal());
    }
    @GetMapping("/report/contractStatistics/{beginCreateTime}/{endCreateTime}")
    public ClientsVO contractStatistics(@PathVariable String beginCreateTime, @PathVariable String endCreateTime){
        log.info("统计合同信息{}",beginCreateTime,endCreateTime);
        ClientsVO res = contractService.queryByDateRange(beginCreateTime, endCreateTime);
        return res;
    }

    /**
     * 销售统计列表
     * @param contractDto
     * @return
     */
    @GetMapping("/report/deptStatisticsList/{beginCreateTime}/{endCreateTime}")
    public PageResultTow contractStatisticsList(@PathVariable String beginCreateTime, @PathVariable String endCreateTime,ContractDto contractDto){
        PageResult res = contractService.SaleList(beginCreateTime,endCreateTime,contractDto);
        return PageResultTow.success(res.getRows(), res.getTotal());
    }

    /**
     * 销售统计
     * @return
     */
    @GetMapping("/report/salesStatistics/{beginCreateTime}/{endCreateTime}")
    public ClientsVO saleCount(@PathVariable String beginCreateTime, @PathVariable String endCreateTime){
        ClientsVO res = contractService.saleCount(beginCreateTime, endCreateTime);
        return res;
    }
}
